<template>
    <el-dialog
  title="表格设置" 
  v-dialogDrag 
  :visible.sync="dialogVisible"
  width="500px"
  custom-class="table-setting-dialog"
  :close-on-click-modal="false">
  
  <div class="dialog-content">

    <div class="setting-body">
      <el-form label-width="80px" size="medium" class="setting-form">
        <el-form-item label="行数" class="form-item-custom">
          <div class="input-with-tips">
            <el-input-number 
              v-model="currentCol" 
              :min="1" 
              :max="50"
              controls-position="right"
              class="custom-input-number"
              placeholder="请输入行数">
            </el-input-number>
            <span class="input-tips">行</span>
          </div>
        </el-form-item>
        
        <el-form-item label="列数" class="form-item-custom">
          <div class="input-with-tips">
            <el-input-number 
              v-model="currentRow" 
              :min="1" 
              :max="26"
              controls-position="right"
              class="custom-input-number"
              placeholder="请输入列数">
            </el-input-number>
            <span class="input-tips">列</span>
          </div>
        </el-form-item>
      </el-form>
    </div>
  </div>
  
    <div class="dialog-footer">
        <el-button @click="handleCancel" class="cancel-btn" round icon="el-icon-close" size="small">取消</el-button>
        <el-button type="primary" @click="handleSave" class="confirm-btn" round icon="el-icon-check" size="small">确认配置</el-button>
    </div>
</el-dialog>
</template>

<script>
export default ({
    props: {
        visible: {
            type: Boolean,
            default: false
        },
    },
    data() {
        return{
            dialogVisible: this.visible,
            currentRow:1,
            currentCol:1
        }
    },
    watch: {
        visible(newVal) {
            this.dialogVisible = newVal
        },
        dialogVisible(newVal) {
            this.$emit('update:visible', newVal)
        },
    },
    methods:{
        handleCancel(){
            this.$emit('cancel')
        },
        handleSave(){
            this.$emit('save',this.currentRow,this.currentCol)
        }
    }
})
</script>
<style scoped lang="scss">
.table-setting-dialog {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  
  .el-dialog__body {
    padding: 0;
  }
  
  .dialog-content {
    padding: 0 24px;
  }
  
  
  .setting-body {
    padding: 24px 0;
  }
  
  .setting-form {
    .form-item-custom {
      margin-bottom: 24px;
      
      .el-form-item__label {
        color: #64748b;
        font-weight: 600;
      }
    }
    
    .input-with-tips {
      display: flex;
      align-items: center;
      gap: 12px;
    }
    
    .custom-input-number {
      width: 120px;
      
      .el-input-number__decrease,
      .el-input-number__increase {
        background: #f8fafc;
        color: #64748b;
        
        &:hover:not(.is-disabled) {
          background: #e2e8f0;
          color: #334155;
        }
      }
      
      .el-input__inner {
        text-align: center;
        font-weight: 500;
      }
    }
    
    .input-tips {
      color: #94a3b8;
      font-size: 14px;
    }
  }
}
</style>
